#include <stdio.h>
#include <stdlib.h>

struct s1 { char a; short b; double c; };
struct s2 { char a; double c; short b; };
struct s3 { char a; double c; short b; int d; };
struct s4 { char a; double c; short b; long e; };
struct s5 { char a; char f[1]; char *g; };
struct s6 { char one[7]; char two[7]; };
struct s7 { struct s6 h; int a; };
struct s8 { char a; struct s6 h; };
struct s9 { int a; struct s6 h; };
struct s10 { struct s9 h; char a; };
struct s11 { char a; struct s9 h; };

int main()
{
    struct s1 tmp1;
    struct s2 tmp2;
    struct s3 tmp3;
    struct s4 tmp4;
    struct s5 tmp5;
    struct s6 tmp6;
    struct s7 tmp7;
    struct s8 tmp8;
    struct s9 tmp9;
    struct s10 tmp10;
    struct s11 tmp11;
	
    printf("sizeof(s1) = %d\n", sizeof(struct s1));
    printf("address of &tmp1 is = %p\n", &tmp1);
    printf("address of tmp1->a = %p \t offset of tmp1->a = %lu\n", &tmp1.a, (long) &((struct s1 *)0)->a);
    printf("address of tmp1->b = %p \t offset of tmp1->b = %lu\n", &tmp1.b, (long) &((struct s1 *)0)->b);
    printf("address of tmp1->c = %p \t offset of tmp1->c = %lu\n\n", &tmp1.c, (long) &((struct s1 *)0)->c);
	
    printf("sizeof(s2) = %d\n", sizeof(struct s2));
    printf("address of &tmp2 is = %p\n", &tmp2);
    printf("address of tmp2->a = %p \t offset of tmp2->a = %lu\n", &tmp2.a, (long) &((struct s2 *)0)->a);
    printf("address of tmp2->c = %p \t offset of tmp2->c = %lu\n", &tmp2.c, (long) &((struct s2 *)0)->c);
    printf("address of tmp2->b = %p \t offset of tmp2->b = %lu\n\n", &tmp2.b, (long) &((struct s2 *)0)->b);
	
    printf("sizeof(s3) = %d\n", sizeof(struct s3));
    printf("address of &tmp3 is = %p\n", &tmp3);
    printf("address of tmp3->a = %p \t offset of tmp3->a = %lu\n", &tmp3.a, (long) &((struct s3 *)0)->a);
    printf("address of tmp3->c = %p \t offset of tmp3->c = %lu\n", &tmp3.c, (long) &((struct s3 *)0)->c);
    printf("address of tmp3->b = %p \t offset of tmp3->b = %lu\n", &tmp3.b, (long) &((struct s3 *)0)->b);
    printf("address of tmp3->d = %p \t offset of tmp3->d = %lu\n\n", &tmp3.d, (long) &((struct s3 *)0)->d);
	
    printf("sizeof(s4) = %d\n", sizeof(struct s4));
    printf("address of &tmp4 is = %p\n", &tmp4);
    printf("address of tmp4->a = %p \t offset of tmp4->a = %lu\n", &tmp4.a, (long) &((struct s4 *)0)->a);
    printf("address of tmp4->c = %p \t offset of tmp4->c = %lu\n", &tmp4.c, (long) &((struct s4 *)0)->c);
    printf("address of tmp4->b = %p \t offset of tmp4->b = %lu\n", &tmp4.b, (long) &((struct s4 *)0)->b);
    printf("address of tmp4->e = %p \t offset of tmp4->e = %lu\n\n", &tmp4.e, (long) &((struct s4 *)0)->e);
    
    printf("sizeof(s5) = %d\n", sizeof(struct s5));
    printf("address of &tmp5 is = %p\n", &tmp5);
    printf("address of tmp5->a = %p \t offset of tmp5->a = %lu\n", &tmp5.a, (long) &((struct s5 *)0)->a);
    printf("address of tmp5->f = %p \t offset of tmp5->f = %lu\n", &tmp5.f, (long) &((struct s5 *)0)->f);
    printf("address of tmp5->g = %p \t offset of tmp5->g = %lu\n\n", &tmp5.g, (long) &((struct s5 *)0)->g);
    
    printf("sizeof(s6) = %d\n", sizeof(struct s6));
    printf("address of &tmp6 is = %p\n", &tmp6);
    printf("address of tmp6->one = %p \t offset of tmp6->one = %lu\n", &tmp6.one, (long) &((struct s6 *)0)->one);
    printf("address of tmp6->two = %p \t offset of tmp6->two = %lu\n\n", &tmp6.two, (long) &((struct s6 *)0)->two);
    
    printf("sizeof(s7) = %d\n", sizeof(struct s7));
    printf("address of &tmp7 is = %p\n", &tmp7);
    printf("address of tmp7->h = %p \t offset of tmp7->h = %lu\n", &tmp7.h, (long) &((struct s7 *)0)->h);
    printf("address of tmp7->a = %p \t offset of tmp7->a = %lu\n\n", &tmp7.a, (long) &((struct s7 *)0)->a);
    
    printf("sizeof(s8) = %d\n", sizeof(struct s8));
    printf("address of &tmp8 is = %p\n", &tmp8);
    printf("address of tmp8->a = %p \t offset of tmp8->a = %lu\n", &tmp8.a, (long) &((struct s8 *)0)->a);
    printf("address of tmp8->h = %p \t offset of tmp8->h = %lu\n\n", &tmp8.h, (long) &((struct s8 *)0)->h);
    
    printf("sizeof(s9) = %d\n", sizeof(struct s9));
    printf("address of &tmp9 is = %p\n", &tmp9);
    printf("address of tmp9->a = %p \t offset of tmp9->a = %lu\n", &tmp9.a, (long) &((struct s9 *)0)->a);
    printf("address of tmp9->h = %p \t offset of tmp9->h = %lu\n\n", &tmp9.h, (long) &((struct s9 *)0)->h);
    
    printf("sizeof(s10) = %d\n", sizeof(struct s10));
    printf("address of &tmp10 is = %p\n", &tmp10);
    printf("address of tmp10->h = %p \t offset of tmp10->h = %lu\n", &tmp10.h, (long) &((struct s10 *)0)->h);
    printf("address of tmp10->a = %p \t offset of tmp10->a = %lu\n\n", &tmp10.a, (long) &((struct s10 *)0)->a);
    
    printf("sizeof(s11) = %d\n", sizeof(struct s11));
    printf("address of &tmp11 is = %p\n", &tmp11);
    printf("address of tmp11->a = %p \t offset of tmp11->a = %lu\n", &tmp11.a, (long) &((struct s11 *)0)->a);
    printf("address of tmp11->h = %p \t offset of tmp11->h = %lu\n\n", &tmp11.h, (long) &((struct s11 *)0)->h);
	
    return 0;
}
